import java.util.Scanner;

public class CranePlacement {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); // 行数
        int m = scanner.nextInt(); // 列数
        int R = scanner.nextInt(); // 吊臂长度
        scanner.nextLine();

        int a = -1, b = -1; // 目标大楼的坐标
        char[][] grid = new char[n][m];

        for (int i = 0; i < n; i++) {
            String row = scanner.nextLine();
            for (int j = 0; j < m; j++) {
                char c = row.charAt(j);
                if (c == '1') {
                    grid[i][j] = '1'; // 标记楼房位置
                } else if (c == '2') {
                    a = i;
                    b = j;
                }
            }
        }

        int count = countPlacableLocations(grid, a, b, R);
        System.out.println(count);
    }

    private static int countPlacableLocations(char[][] grid, int a, int b, int R) {
        int count = 0;
        int n = grid.length;
        int m = grid[0].length;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (grid[i][j] != '1' && isPlacable(i, j, a, b, R)) {
                    count++;
                }
            }
        }

        return count;
    }

    private static boolean isPlacable(int k, int m, int a, int b, int R) {
        int distanceToTarget = Math.abs(k - a) + Math.abs(m - b);
        return distanceToTarget <= R;
    }
}
